<?
function err($err){
	$errorMsg = $err;
	include("index.html");
	exit();
}
if (getenv(REQUEST_METHOD) == "POST"){

	include("../variables.php");
	$username = $HTTP_POST_VARS[username];
	$reseller = $HTTP_POST_VARS[reseller];
	$email = $HTTP_POST_VARS[email];
	$phone = $HTTP_POST_VARS[phone];
	$country = $HTTP_POST_VARS[country];
	$subject = $HTTP_POST_VARS[subject];
	$message = $HTTP_POST_VARS[message];

	if(!validate($reseller)) err("Invalid  name");
	if($username && !validate($username)) err("Invalid username");
	if(!validate($email)) err("Invalid email");
	if(!validate($phone)) err("Invalid phone");
	if(!validate($subject)) err("Invalid sublect");
	//if(!validate($message)) err("invalid name");
	
	$data = "
USERNAME : $username
NAME : $reseller
MAIL : $email
PHONE : $phone
COUNTRY : $country

SUBJECT : $subject
MESSAGE : $message
";
	if(!mail("support@resellerspanel.com","[Resellers System - Contact us]","$data","From: $email")) err("Error.");
	
	include("contactus_ok.html");	
	exit();
}
?>
